<template>
  <a-drawer v-model:visible="visible" title="知识库管理详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="文件唯一标识">{{ dataDetail?.fileId }}</a-descriptions-item>
      <a-descriptions-item label="文件名">{{ dataDetail?.fileName }}</a-descriptions-item>
      <a-descriptions-item label="物理存储路径">{{ dataDetail?.physicalPath }}</a-descriptions-item>
      <a-descriptions-item label="逻辑文件夹路径">{{ dataDetail?.logicalPath }}</a-descriptions-item>
      <a-descriptions-item label="父文件夹ID">{{ dataDetail?.parentFolderId }}</a-descriptions-item>
      <a-descriptions-item label="文件大小（字节）">{{ dataDetail?.fileSize }}</a-descriptions-item>
      <a-descriptions-item label="文件类型">{{ dataDetail?.fileType }}</a-descriptions-item>
      <a-descriptions-item label="是否文件夹">{{ dataDetail?.isFolder }}</a-descriptions-item>
      <a-descriptions-item label="创建者">{{ dataDetail?.createdBy }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createdAt }}</a-descriptions-item>
      <a-descriptions-item label="更新时间">{{ dataDetail?.updatedAt }}</a-descriptions-item>
      <a-descriptions-item label="删除标记">{{ dataDetail?.isDeleted }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUser }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createTime }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUser }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
      <a-descriptions-item label="修改时间">{{ dataDetail?.updateTime }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script setup lang="ts">
  import {useWindowSize} from '@vueuse/core'
  import {
        type
        KnowledgeDetailResp,
        getKnowledge as getDetail
    } from '@/apis/knowledge/knowledge'

const { width } = useWindowSize()

const dataId = ref('')
const dataDetail = ref<KnowledgeDetailResp>()
const visible = ref(false)

// 查询详情
const getDataDetail = async () => {
  const { data } = await getDetail(dataId.value)
  dataDetail.value = data
}

// 打开
const onOpen = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onOpen })
</script>

<style scoped lang="scss"></style>
